package cn.itcast.mapper;

import cn.itcast.dto.DishDto;
import cn.itcast.dto.SetmealDto;
import cn.itcast.entity.Dish;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ISetmealMapper {
    @Insert("insert into setmeal values(null,#{categoryId},#{name},#{price},#{status},#{code},#{description}" +
            ",#{image},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    void save(SetmealDto setmealDto);

    @Select("SELECT COUNT(*) FROM setmeal WHERE category_id =#{id}")
    int findCount(Long id);

    List<SetmealDto> findByName(Integer pageNum,Integer pageSize,String name);

    @Select("SELECT s.*,c.`name` categoryName FROM setmeal s LEFT JOIN category c ON s.`category_id` = c.`id` WHERE s.`id`=#{id}")
    SetmealDto findById(Long id);


    int findWithStatus(@Param("ids") Long[] ids);

    void delete(Long[] ids);

    @Select("select * from setmeal where category_id=#{categoryId} and status=#{status}")
    List<SetmealDto> list(@Param("categoryId") Long categoryId, @Param("status") Integer status);
}
